/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBean.TX.TCube;

import session.TX.DishManagerSBRemote;
import session.TX.OutletSBRemote;
import entity.FoodItem;
import entity.Outlet;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Lu Xiaodi
 */
@ManagedBean(name = "dishManagedBeanTCube")
@RequestScoped
public class DishManagedBeanTCubeMB {

    @EJB
    DishManagerSBRemote dishBean;
    @EJB
    OutletSBRemote outletBean;
    Long itemId;
    Long outletId;
    List<Outlet> allOutlets;

    /** Creates a new instance of DishManagedBeanTCubeMB */
    public DishManagedBeanTCubeMB() {
    }

    public List<Outlet> getAllOutlets() {
        return outletBean.getAllOutlets();
    }

    public List<FoodItem> getAllPromotionDishes() {
        return dishBean.getAllPromotionalDishes();
    }

    public List<FoodItem> getAllDishes() {
        if (outletId == null) {
            //throw outletId not found exception
            return null;
        }
        return dishBean.getNonDeliItemForSale(outletId);
    }

    public void lockDish(ActionEvent event) {
        Long id = (Long) event.getComponent().getAttributes().get("dishId");
        dishBean.lockFoodItem(id);
    }

    public void unlockDish(ActionEvent event) {
        Long id = (Long) event.getComponent().getAttributes().get("dishId");
        dishBean.unlockFoodItem(id);
    }
    
    
    //getter and setters

    public Long getItemId() {
        return itemId;
    }

    public void setItemId(Long itemId) {
        this.itemId = itemId;
    }

    public Long getOutletId() {
        return outletId;
    }

    public void setOutletId(Long outletId) {
        this.outletId = outletId;
    }
    
}
